<style itemscope>

    .layui-form-label.required:before { /* 这种写法也可以*/
        content: ' *';
        color: red;
    }

    .addProductionPlanForm-title .title, .examineProductionPlanForm-title .title {
        display: inline-block;
        margin: 20px;
        font-size: 16px;
        font-weight: bold;
        color: #333333;
        line-height: 19px;
        position: relative;
        padding: 6px 0 19px 0;
    }

    .addProductionPlanForm-title .title:after, .examineProductionPlanForm-title .title:after {
        content: '';
        display: block;
        position: absolute;
        left: 0;
        bottom: 0;
        width: calc(100% + 6px);
        height: 3px;
        background: #0A8B0A;
    }

    .layui-form-label {
        float: left;
        display: block;
        padding: 9px 15px;
        width: 80px;
        font-weight: 400;
        line-height: 20px;
        text-align: right;
    }

    .layui-form-select dl {
        left: 33px;
        min-width: 85%;
    }
</style>
<script type="text/javascript" src="../../../admin/assets/js/pdfobject.min.js"></script>
<!-- 表单弹窗 -->
<form lay-filter="taskQualityRecordForm" class="layui-form open-form">
    <div class="open-model">
        <div class="open-auto">
            <div class="examineProductionPlanForm-title">
                <h3 class="title" style="margin-top: 0;">工单信息</h3>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-col-md4">
                    <label class="layui-form-label w-auto">开工单：</label>
                    <div class="layui-input-block">
                        <input id="workOrderCode" disabled name="workOrderCode" placeholder="开工单" type="text"
                               class="layui-input"
                               autocomplete="off"/>
                    </div>
                </div>

                <div class="layui-col-md4">
                    <label class="layui-form-label w-auto">所属计划：</label>
                    <div class="layui-input-block">
                        <input id="planCode" disabled name="planCode" placeholder="所属计划" type="text"
                               class="layui-input"
                               autocomplete="off"/>
                    </div>
                </div>

                <div class="layui-col-md4">
                    <label class="layui-form-label w-auto">物料编码：</label>
                    <div class="layui-input-block">
                        <input id="skuCode" disabled name="skuCode" placeholder="物料编码" type="text" class="layui-input"
                               autocomplete="off"/>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-col-md4">
                    <label class="layui-form-label w-auto">物料名称：</label>
                    <div class="layui-input-block">
                        <input id="skuName" disabled name="skuName" placeholder="物料名称" type="text" class="layui-input"
                               autocomplete="off"/>
                    </div>
                </div>
            </div>
            <div class="examineProductionPlanForm-title">
                <h3 class="title">任务配置</h3>
            </div>
            <!-- 表单 -->
            <div class="layui-form-item layui-row">
                <div class="layui-col-md4">
                    <label class="layui-form-label required">质检性质：</label>
                    <div class="layui-input-block">
                        <select id="qualityTestingNatureId" name="qualityTestingNatureId"
                                lay-filter="qualityTestingNatureId"
                                class="common-select-search">
                        </select>
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label w-auto required">质检类型：</label>
                    <div class="layui-input-block">
                        <select id="qualityTestingTypeId" disabled name="qualityTestingTypeId"
                                lay-filter="qualityTestingTypeId"
                                class="common-select-search">
                        </select>
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label w-auto required">质检分类：</label>
                    <div class="layui-input-block">
                        <select id="qualityTestingCategoryId" name="qualityTestingCategoryId"
                                lay-filter="qualityTestingCategoryId"
                                class="common-select-search">
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-col-md4">
                    <label class="layui-form-label w-auto required">送检数量：</label>
                    <div class="layui-input-block">
                        <input id="submissionQuantity" name="submissionQuantity" placeholder="请输入数量"
                               type="text"
                               class="layui-input"
                               autocomplete="off"/>
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label w-auto required">送检工位：</label>
                    <div class="layui-input-block">
                        <select id="inspectDeviceCode" lay-search="" name="inspectDeviceCode"
                                lay-filter="inspectDeviceCode"
                                class="common-select-search">
                        </select>
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label w-auto required">载具编码：</label>
                    <div class="layui-input-block">
                        <input id="carrierCode" name="carrierCode" placeholder="请输入载具编码" type="text"
                               class="layui-input"
                               autocomplete="off"/>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-col-md4">
                    <label class="layui-form-label w-auto">送检备注：</label>
                    <div class="layui-input-block">
                        <input id="remark" name="remark" placeholder="请输入备注" type="text" class="layui-input"
                               autocomplete="off"/>
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label w-auto required">状态：</label>
                    <div class="layui-input-block">
                        <input id="statusDesc" style="border: none" disabled name="statusDesc" placeholder="待确认"
                               type="text"
                               class="layui-input"
                               autocomplete="off"/>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn" lay-filter="qualityRecordDetailFormSubmit" lay-submit>保存</button>
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        </div>
    </div>
</form>

<!--选择质检任务单-->
<script type="text/html" id="selectQualityTaskTemplate">
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 头部操作栏 -->
                <div class="layui-form toolbar">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label w-auto">质检任务单编号：</label>
                            <div class="layui-input-inline mr0" style="width: 240px;">
                                <input name="code" class="layui-input" type="text" placeholder="质检任务编号"/>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn icon-btn" lay-filter="selectTheWorkProcessFormSubSearchLog"
                                    lay-submit style="padding: 0 24px;">
                                搜索
                            </button>
                            <button id="selectTaskQualityClose" class="layui-btn icon-btn">确认选择</button>
                        </div>
                    </div>
                </div>
                <!-- 表格 -->
                <table class="layui-table" id="selectQualityTaskTable"
                       lay-filter="selectQualityTaskTable"></table>
            </div>
        </div>
    </div>
</script>

<script type="text/html" id="viewAttachmentHtml">
    <div id="example1" style="height: 100%;"></div>
</script>

<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table', 'laydate', 'admin', 'laytpl', 'upload', 'config'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var config = layui.config;
        var upload = layui.upload;
        var table = layui.table;
        var admin = layui.admin;
        var form = layui.form;

        //选择开工单
        let templateData = admin.getTempData("workOrderData");

        //质检性质
        admin.getDictList("qualityTestingNatureId", "sys_product_type_nature", 2, "质检性质");
        //送检类型
        admin.initDataSelectAndMap('production/qualityTesting/admin/qualityTestingType/list', {limit: 9999}, "qualityTestingTypeId", 1, "送检类型", "name", "id", null);
        //质检分类
        admin.initDataSelectAndMap('production/qualityTesting/admin/qualityTestingCategory/list', {limit: 9999}, "qualityTestingCategoryId", null, "质检分类", "name", "id", null);

        //初始化送检工位
        admin.initDataSelect('enterprise/device/admin/device/list', {limit: 9999}, "inspectDeviceCode", null, "送检工站", "deviceName", "deviceCode");

        //修改
        if (templateData) {
            //显示值
            form.val("taskQualityRecordForm", templateData);
            $("#taskId").val(templateData.id);
            $("#testingCategoryName").val(templateData.testingCategoryName);
            $("#testingTypeName").val(templateData.productTypeName);
            $("#qualityTestingNatureName").val(templateData.qualityTestingNatureName);
            $("#planCode").val(templateData.processName);
            $("#carrierCode").val(templateData.carrierCode);

        }
        // // 表单提交事件
        form.on('submit(qualityRecordDetailFormSubmit)', function (d) {
            layer.load(2);
            d.field.workOrderId = templateData.workOrderId;
            d.field.processId = templateData.processId;
            d.field.processName = templateData.planCode;
            admin.req('production/productionPlan/admin/productionWorkOrder/addFirstTask', JSON.stringify(d.field), function (res) {
                layer.closeAll('loading');
                if (res.code == 200) {
                    layer.msg(res.msg, {icon: 1});
                    layer.closeAll('page');
                } else {
                    layer.msg(res.msg, {icon: 2});
                }
            }, 'POST', true, "application/json; charset=utf-8");
            return false;
        });
    });
</script>